home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 4
/
Apprentice-Release4.iso
/
Languages
/
THIN C 2.0
/
Projects
/
listPrimes
/
listPrimes.c
next >
Encoding:
Amiga
Atari
Commodore
DOS
FM Towns/JPY
Macintosh
Macintosh JP
Macintosh to JP
NeXTSTEP
RISC OS/Acorn
Shift JIS
UTF-8
Wrap
C/C++ Source or Header
|
1991-05-03
|
361 b
|
27 lines
|
[
TEXT/THIN
]
#include <stdio.h>
IsItPrime( int candidate )
{
int i, foundFactor;
foundFactor = FALSE;
for ( i = 2; i < candidate; i++ )
{
if ( (candidate / i) * i == candidate )
foundFactor = TRUE;
}
return( foundFactor == FALSE );
}
main()
{
int i;
for ( i = 1; i <= 50; i++ )
{
if ( IsItPrime( i ) )
printf( "%d is a prime number.\n", i );
}
}